|
|
|
|
|
|
|
Figure 5.5.
Adding the Dollars
control to the form. |
|
|
|
|
|
|
|
|
Now run the program and enter a numeric value in the Dollars textbox. When you leave the textbox to go to another control, you see the MaskedEdit control format the display of the amount you entered. Your screen should resemble Figure 5.6. Please note that two decimal places always appear to the right of the decimal. |
|
|
|
|
|
|
|
|
Figure 5.6.
The display results of
the MaskedEdit control. |
|
|
|
|
|
|
|
|
One of the most common field-level input validation routines is the use of a validation list. The list contains a set of possible inputs for the fieldusually displayed in a list box or a drop-down list control. Instead of having to guess at a valid value, the user can simply scan the list and click on the proper choice. Validation lists require a bit more programming to use, but the rewards far exceed the effort. Using validation lists virtually guarantees that you will not have a data entry error occur on the input field. |
|
|
|
|
|
|
|
|
Before you can use a validation list for input validation, you must first have a list. It is usually a good idea to load any validation lists you need for a form at the time you load the form. This means that validation lists should be loaded in the Form_Load event. Let's add some code to your project that loads a drop-down list box with a list of possible customer types. |
|
|
|
|
|